IBuffCondition = {};
IBuffCondition.__index = IBuffCondition;

function IBuffCondition:new()
    local object = {};
    setmetatable(object, IBuffCondition);
    return object;
 end

function IBuffCondition:pass(fight,buff,conditionParameters,...)
end

BuffCondition1 = {};
BuffCondition1.__index = BuffCondition1;

function BuffCondition1:pass(fight,buff,conditionParameters,...)
    -- 普通攻击
    local skill = select('2', ...);
    local skillBean = skill.skill.skillBean;
    
    -- 普通攻击
    if skillBean.f_SkillType == EnumConst.SkillTypeEnum.NORMAL_ATTACK then
        return true;
    end
    return false;
end

BuffCondition2 = {};
BuffCondition2.__index = BuffCondition2;

function BuffCondition2:pass(fight,buff,conditionParameters,...)
    -- 治疗技能
    local skill = select('2', ...);
    local skillBean = skill.skill.skillBean;

    if skillBean.f_HurtMethod == EnumConst.SkillDamageTypeEnum.HEAL then
        return true;
    end
    return false;
end

BuffCondition3 = {};
BuffCondition3.__index = BuffCondition3;

function BuffCondition3:pass(fight,buff,conditionParameters,...)
    -- 生命值高于对方(生命值低于自身)
    local target = select('1', ...);

    if buff.source.hp >= target.hp then
        return true;
    end
    return false;
end

BuffCondition4 = {};
BuffCondition4.__index = BuffCondition4;

function BuffCondition4:pass(fight,buff,conditionParameters,...)
    -- 自身生命值低于一定百分比
    local target = buff.target;

    -- 计算边界值
    local value = FighterAttributeManager.getFightAttr(target, EnumConst.FighterAttributeEnum.HP) * conditionParameters[2] / EnumConst.TEN_THOUSANDTH;

    if target.hp < value then
        return true;
    end
    return false;
end

BuffCondition5 = {};
BuffCondition5.__index = BuffCondition5;

function BuffCondition5:pass(fight,buff,conditionParameters,...)
    -- 触发次数小于等于n次
    if buff.triggerTimes < conditionParameters[2] then
        return true;
    end
    return false;
end

BuffCondition6 = {};
BuffCondition6.__index = BuffCondition6;

function BuffCondition6:pass(fight,buff,conditionParameters,...)
    -- 堆叠达到最大数量
    if buff.overlay == buff.buffBean.f_MaxReplaceLyer then
            return true;
    end
    return false;
end

BuffCondition7 = {};
BuffCondition7.__index = BuffCondition7;

function BuffCondition7:pass(fight,buff,conditionParameters,...)
    local fighters = fight.teams[1 - buff.target.teamIndex].fighters;
    local size = 0;
    for i=1,#fighters do
        if not FighterManager.isDie(fighters[i]) then
            size = size + 1;
        end
    end
    -- 场上敌人少于n
    if size < conditionParameters[2] then
        return true;
    end
    return false;
end


BuffCondition8 = {};
BuffCondition8.__index = BuffCondition8;

function BuffCondition8:pass(fight,buff,conditionParameters,...)
    local frames = conditionParameters[2] / EnumConst.FIGHT_FRAME;
    -- 触发间隔不少于n毫秒
    if buff.triggerFrame + frames < fight.frame then
        return true;
    end
    return false;
end


BuffCondition9 = {};
BuffCondition9.__index = BuffCondition9;

function BuffCondition9:pass(fight,buff,conditionParameters,...)
    -- -- 治疗技能
    -- local skill = select('2', ...);
    -- local skillBean = skill.skill.skillBean;

    -- if skillBean.f_TriggerFigthHurt == EnumConst.SkillDamageTypeEnum.NORMAL then
    --     return true;
    -- end
    return false;
end


BuffCondition22 = {};
BuffCondition22.__index = BuffCondition22;

function BuffCondition22:pass(fight,buff,conditionParameters,...)
    local times = 1;
    if buff.conditionParameters["BuffCondition22"] ~= nil and buff.conditionParameters["BuffCondition22"] ~= "" then
        times = buff.conditionParameters["BuffCondition22"];
        times = times + 1;
    end
    buff.conditionParameters["BuffCondition22"] = times;
    -- 被触发次数为n的整数倍
    if times % conditionParameters[2] == 0 then
        return true;
    end

    return false;
end

BuffCondition23 = {};
BuffCondition23.__index = BuffCondition23;

function BuffCondition23:pass(fight,buff,conditionParameters,...)
    local skill = select('2', ...);
    -- 触发技能id
    if skill.skill.skillBean.f_SkillID == conditionParameters[2] then
        return true;
    end
    return false;
end
